Example: The following example shows how to use page numbering in a document and how to use artifact.
import com.cete.dynamicpdf.*; import com.cete.dynamicpdf.pageelements.*; public class MyClass{ public static void main(String args[]){ // Create a PDF Document Document document = new Document(); // Specify document as a tagged PDF document.setTag(new TagOptions()); // Create a document template and add it to the document Template documentTemplate = new Template(); document.setTemplate(documentTemplate); String numberText = "PageNumberingLabels contain page numbering: %%CP%% of %%TP%% pages."; // Create a Page numbering label PageNumberingLabel pageNumberingLabel = new PageNumberingLabel(numberText, 0, 680, 512, 12, Font.getHelvetica(), 12, TextAlign.CENTER); // Create an artifact and add its type to pagination Artifact artifact = new Artifact(); artifact.setType(ArtifactType.PAGINATION); // Tag the page numbering label with the artifact pageNumberingLabel.setTag(artifact); // Add page numbering label to the document template documentTemplate.getElements().add(pageNumberingLabel); // Begin the first section document.getSections().begin(NumberingStyle.ROMAN_LOWERCASE); // Add three pages to the document Page page1 = new Page(); page1.getElements().add(new Label("This is the first page", 100, 100, 200, 100)); document.getPages().add(page1); Page page2 = new Page(); page2.getElements().add(new Label("This is the second page", 100, 100, 200, 100)); document.getPages().add(page2); Page page3 = new Page(); page3.getElements().add(new Label("This is the third page", 100, 100, 200, 100)); document.getPages().add(page3); // Save the PDF document.draw("[Physicalpath]/MyDocument.pdf" ); } }